package com.example.hotel_demo.mapper;

import com.example.hotel_demo.pojo.RoomType;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Mapper
public interface RoomTypeMapper {



    @Select("select * from room_type where name = #{name};")
    public RoomType getRoomTypeByName(String typeName);

    @Select("select count(*) from roomtype")
    public int getTypeCount();

    @Insert("insert into room_type (typeName,roomPrice,roomArea,rateNum,rateBed) values (#{typeName},#{roomPrice},#{roomArea},#{rateNum},#{rateBed})")
    public int addRoomType(String typeName,int roomPrice,int roomArea, int rateNum, int rateBed);

    @Update("update room_type set roomPrice = #{roomPrice} where typeName = #{typeName}")
    public int updateRoomPriceByTypeName(String typeName ,int roomPrice);

    @Delete("delete from room_type where typename = #{typeName}")
    public int deleteRoomTypeByTypeName(String typeName);

    @Update("update roomtype set avilableNum=#{avilableNum},bookNum=#{bookNum} where typeID=#{typeID}")
    int updateroomNum(RoomType roomType);

    @Select("select * from roomtype where typeID=#{typeID}")
    RoomType findById(int typeID);

    @Select("select * from roomtype")
    public List<RoomType> getRoomTypeAll();

    @Select("select price from roomtype where typeID=#{typeID}")
    int getRoomPriceBYid(int typeID);
}
